package com.product.android.ui.anim;

import java.util.Collections;
import java.util.LinkedList;
import java.util.List;

import android.graphics.Bitmap;
import android.view.View;
import android.widget.ImageView;

import com.nostra13.universalimageloader.core.assist.SimpleImageLoadingListener;
import com.nostra13.universalimageloader.core.display.FadeInBitmapDisplayer;

/**
 * 使用imageloader时的显示动画
 * ClassName:AnimateFirstDisplayListener
 * Function: TODO ADD FUNCTION
 * Reason:	 TODO ADD REASON
 * 
 * @author   黄永鑫		
 * @version  
 * @since    Ver 1.1
 * @Date	 2014	2014-2-11		上午11:50:05
 *
 * @see
 */
public class AnimateFirstDisplayListener extends SimpleImageLoadingListener {

	final List<String> displayedImages = Collections
			.synchronizedList(new LinkedList<String>());

	@Override
	public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
		if (loadedImage != null) {
			ImageView imageView = (ImageView) view;
			boolean firstDisplay = !displayedImages.contains(imageUri);
			if (firstDisplay) {
				FadeInBitmapDisplayer.animate(imageView, 500);
				displayedImages.add(imageUri);
			}
		}
	}
}
